package com.cy.java.basic;

import java.util.HashMap;
import java.util.Map;

class Point{
    //对象再GC前会执行此方法
        @Override
        protected  void finalize() throws Throwable{
            System.out.println("finalize()");
        }
}
public class GCTest01 {
    public static void main(String[] args) {
        Map<String,Object> beanPool = new HashMap<>();//假设是用与存储对象的一个池
        Point p1 = new Point();
        beanPool.put("key1",p1);
        p1=null;
        beanPool.clear();
        System.gc();//启动GC
    }
}
